package com.heima.home.service.impl;


import com.heima.home.dto.BookingListItemDTO;
import com.heima.home.entity.Bookings;
import com.heima.home.mapper.BookingMapper;
import com.heima.home.service.BookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookingServiceImpl implements BookingService {

    @Autowired
    private BookingMapper bookingMapper;
    @Override
    public Bookings selectBookingById(Integer id) {
        Bookings bookings = bookingMapper.selectBookingById(id);
        return bookings;
    }
    @Override
    public List<BookingListItemDTO> getUserBookings(Integer userId) {
        System.out.println(">>> 正在为 user_id = " + userId + " 查询订单...");
        List<BookingListItemDTO> result = bookingMapper.findByUserId(userId);
        System.out.println(">>> 数据库查询完成，找到 " + (result == null ? 0 : result.size()) + " 条订单。");
        return result;
    }
}
